package com.sz.designpattern.create5.prototype;

import java.util.ArrayList;

public class Person implements Cloneable {
    private String name;
    private Action action;
    private ArrayList<String> list = new ArrayList<>();

    public ArrayList<String> getList() {
        return list;
    }

    public void setList(ArrayList<String> list) {
        this.list = list;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Action getAction() {
        return action;
    }

    public void setAction(Action action) {
        this.action = action;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person person = null;
        person = (Person) super.clone();
        //属性的值 复制
//        person.name = this.name;
        //非基本类型
        person.action = (Action) this.action.clone();
        person.list = (ArrayList<String>) this.list.clone();
        return person;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", action=" + action +
                ", list=" + list +
                '}';
    }
}
